import request from '@/utils/request'

export default {
    getAllStaffsMessage() {
        const req = request({
            method: 'get',
            url: '/dgut/getAllEmployeesMessage'
        })
        return req;
    },
    getOneStaff(eid){
        const req = request({
            method: 'get',
            url: '/dgut/getEmployeesMessageById',
            params: {
                eid
            }
        })
        console.log(req)
        return req;
    },
    editOneStaff(Message){
        const req = request({
            method: 'put',
            url: '/dgut/updateOneEmployeesMessage',
            params: {
                eid: Message.eid,
                ename: Message.ename,
                ephone: Message.ephone,
                esalary: Message.esalary,
                edepartment: Message.edepartment
            }
        })
        return req;
    },
    deleteOneStaff(eid){
        const req = request({
            method: 'delete',
            url: '/dgut/deleteOneEmployeesMessage',
            params: {
                eid
            }
        })
        return req;
    },
    addOneStaff(Message) {
        const req = request({
            method: 'post',
            url: '/dgut/addOneEmployeesMessage',
            params: {
                ename: Message.ename,
                ephone: Message.ephone,
                esalary: Message.esalary,
                edepartment: Message.edepartment
            }
        })
        return req;
    },
    search(searchMap){
        if (searchMap.eid != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getEmployeesMessageById',
                params: {
                    eid:searchMap.eid
                }
            })
            return req;
        } else if (searchMap.ename != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getEmployeesMessageByName',
                params: {
                    ename:searchMap.ename
                }
            })
            return req;
        } else if (searchMap.ephone != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getEmployeesMessageByPhone',
                params: {
                    ephone:searchMap.ephone
                }
            })
            return req;
        } else if (searchMap.edepartment != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getEmployeesMessageByDepartment',
                params: {
                    edepartment:searchMap.edepartment
                }
            })
            return req;
        } else {
            const req = request({
                method: 'get',
                url: '/dgut/getAllEmployeesMessage'
            })
            return req;
        }
    }
}